import torch

# x = torch.arange(4.0)
# print(x)
# x.requires_grad_(True)
# y = 2 * torch.dot(x, x)
# print(y)
# y.backward()
# print(x.grad)
#
# x.grad.zero_()
# print(x)
# y = x.sum()
# y.backward()
# x.grad

# x = torch.arange(4.0)
# print(x)
# x.requires_grad_(True)
x = torch.tensor([1.0,2.0,3.0,4.0],requires_grad=True)
y = x ** 2

print(y.mean())
# y.backward()
print(x.grad)
